import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    isFlage:false,//判断横竖
    isBig:false,//判断大小
    isClude:"",//存放输入框的值
    list:[{text:"text1",id:1},{text:"text2",id:2},{text:"text3",id:3},{text:"text4",id:4},{text:"text5",id:5}]

  },
  getters:{
    includeMessage(state){
      return state.list.filter(item=>item.text.includes(state.isClude))
    }
  },
  mutations: {
    //横竖操作
    medifyCilic(state,payload){
      state.isFlage=payload
      console.log(state.isFlage)
    },
    //大小操作
    medifyBig(state,payload){
      state.isBig=payload
      // console.log(state.isBig)
      if(state.isBig==true){
        state.list=state.list.sort((a, b) => b.id - a.id)
      } else {
        state.list=state.list.sort((a, b) => a.id - b.id)
      }
    },
    //添加操作
    medifyAdd(state,payload){
      state.list.push({text:payload,id:state.list.length+1})
    },
    //搜索操作
    medifySearch(state,payload){
       // state.list=state.list.filter(item=>item.text.includes(payload))
      state.isClude=payload
    }
  },
  actions: {
  },
  modules: {
  }
})
